home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / HippoDraw / HippoDrawSrc1.1 / Hippo.subproj / InspectStat.m < prev    next >
Encoding:
Text File  |  1992-04-25  |  2.7 KB  |  130 lines

  1. /* InspectStat.h        by Paul Kunz    December 1991
  2.  * Controls binding of the plot axes with the columns of the tuple.
  3.  *
  4.  * Copyright (C)  1991  The Board of Trustees of
  5.  * The Leland Stanford Junior University.  All Rights Reserved.
  6.  */
  7.  
  8. #import "InspectStat.h"
  9.  
  10. const char InspectStat_h_rcsid[] = INSPECTSTAT_H_ID;
  11. const char InspectStat_m_rcsid[] = "$Id: InspectStat.m,v 1.10 1992/04/21 00:53:13 pfkeb Rel $";
  12.  
  13. #import <appkit/Application.h>
  14. #import <appkit/Box.h>
  15. #import <appkit/Matrix.h>
  16. #import <appkit/TextField.h>
  17.  
  18. #import "HGraphicView.h"
  19. #import "NewInspector.h"
  20. #import "Plot.h"
  21.  
  22. #import "hippo.h"
  23.  
  24. @implementation InspectStat
  25.  
  26. - initInspFor:aDraw
  27. {    
  28.     [super initInspFor:aDraw];
  29.     
  30.     [NXApp loadNibSection:"InspectStat.nib" owner:self
  31.            withNames:NO fromZone:[self zone]];
  32.     [theInspector addView:[contentBox contentView]
  33.                   withName:"Plot Statistics" withSupervisor:self];
  34.     return self;
  35. }
  36.  
  37. - createImage:sender
  38. {
  39.     id        statView;
  40.     NXStream     *s;
  41.     NXRect    rect, prect;
  42.     
  43.     statView = [statBox contentView];
  44.     
  45.     s = NXOpenMemory(NULL, 0, NX_READWRITE);
  46.     if (s) {
  47.         [statView getFrame:&rect];
  48.         [statView copyPSCodeInside:&rect to:s]; 
  49.     }
  50.     NXSeek(s, 0L, NX_FROMSTART);
  51.     [selectedPlot getBounds:&prect];
  52.     [graphicView loadImageFromStream:s at:&prect.origin allowAlpha:YES];
  53.     NXCloseMemory(s, NX_FREEBUFFER);
  54.     return self;
  55. }
  56. /* Methods for updating Inspector */
  57. - updateView
  58. {    
  59.     [self showStats];
  60.     return self;
  61. }
  62. - updateEmptySelection
  63. {
  64.     [self clearStats];
  65.     return self;
  66. }
  67. - updateMultiSelection
  68. {
  69.     selectedPlot = nil;
  70.     [self clearStats];
  71.     return self;
  72. }
  73. - clearStats
  74. {
  75.     int        c, r;
  76.     
  77.     for( c = 0; c < 3; c++ ) {
  78.         for( r = 0; r < 3; r++ ) {
  79.         [[statMatrix cellAt:r :c] setStringValue:""];
  80.     }
  81.     }
  82.     [statMatrix setEnabled:NO];
  83.     return self;
  84. }
  85. - showStats
  86. {
  87.     id        aCell;
  88.     display    disp;
  89.     graphtype_t    graphType;
  90.     int        c, r;
  91.  
  92.     selectedPlot = [graphicView firstPlot];
  93.     if ( !selectedPlot ) {
  94.         [self clearStats];
  95.         return self;
  96.     }
  97.     disp = [selectedPlot histDisplay];
  98.     graphType = h_getDispType( disp );
  99.  
  100.     [statMatrix setEnabled:YES];
  101.     if (graphType == HISTOGRAM)
  102.     {
  103.      for ( r = 0; r < 3; r++ ) {
  104.         for ( c = 0; c < 3; c++ ) {
  105.             aCell = [statMatrix cellAt:r :c ];
  106.             if ( r == 1 ) {
  107.                 [aCell setFloatValue:h_getTotal(disp,c,0) ];
  108.             } else {
  109.                 [aCell setStringValue:""];
  110.             }
  111.         }
  112.     }
  113.     }
  114.     else
  115.     {
  116.      for ( c = 0; c < 3; c++ )
  117.      {
  118.           for ( r = 0; r < 3; r++ )
  119.           {
  120.            aCell = [statMatrix cellAt:r :c];
  121.            [aCell setFloatValue:h_getTotal(disp,c,2-r) ];
  122.           }
  123.      }
  124.     }
  125.  
  126.     return self;
  127. }
  128.     
  129. @end
  130.